const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const webpack = require('webpack');

module.exports = {
  entry: {
    app: './src/index.js'
  },
  plugins: [
    new CleanWebpackPlugin(['dist']),
    new HtmlWebpackPlugin({
      title: 'Hot Module Replacement'
    }),
     new webpack.NamedModulesPlugin(),
     new webpack.HotModuleReplacementPlugin()
  ],
  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist'),
    publicPath:'temp/'
  },
  devServer:{
    contentBase:'./',
    host:'localhost',
    compress:true,
    port:8080,
    hot: true
  },
  module:{
    rules:[
      {
        test:/\.js$/,
        exclude:/node_modules/,
        loaders:"babel-loader",
        query:{
            presets:['es2015','react']
        }
      }
    ]
  }
};